package com.example.zxmzy.xl;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.fragment.app.Fragment;

import com.example.zxmzy.R;
import com.example.zxmzy.activity.AboutActivity;
import com.example.zxmzy.activity.RecordActivity;
import com.example.zxmzy.entity.User;
import com.example.zxmzy.utils.CurrentUserUtils;

public class MeXl extends Fragment {

   private TextView tvName;
   private LinearLayout llRecord, llChangeAddress, llInfo, llAbout, llContact;

    private User user;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         user = CurrentUserUtils.getCurrentUser();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.xl_me, container, false);
        bindView(v);
        initView();
        return v;
    }

    private void bindView(View v) {
        llRecord = v.findViewById(R.id.myrecord);
        tvName = v.findViewById(R.id.ti_name);
        llAbout = v.findViewById(R.id.ll_about);
        llContact = v.findViewById(R.id.ll_contact);
    }

    private void initView() {
        tvName.setText("欢迎光临，圈圈小铺" );
        llAbout.setOnClickListener(this::onClick);
        llRecord.setOnClickListener(this::onClick);
        llContact.setOnClickListener(this::onClick);

    }
    void onClick(View v) {
        int id = v.getId();
        if (id == R.id.myrecord) {//Toast.makeText(getContext(), "record", Toast.LENGTH_SHORT).show();
            Intent intent = new Intent(getActivity(), RecordActivity.class);
            startActivity(intent);
        } else if (id == R.id.ll_contact) {
            joinPhone();
        }  else if (id == R.id.ll_about) {
            Intent intent3 = new Intent(getActivity(), AboutActivity.class);
            startActivity(intent3);
        }
    }


    void joinPhone() {
        Toast.makeText(getContext(), "请联系：15230008975", Toast.LENGTH_SHORT).show();
    }

}